/* GUI CONVERTED from rqpoiq.p (converter v1.76) Sun Jan 26 20:19:12 2003 */
/* rqpoiq.p -  PURCHASE ORDER vs REQUISITION NBR                            */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.5.1.4 $                                                         */

/*V8:ConvertMode=Report                                                     */
/* REVISION 8.5             CREATED: 06/13/97  BY: *J1Q2* Vinay Nayak-Sujir */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 04/30/98   BY: *K1P0* A. Shobha */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Brian Compton    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                */
/* $Revision: 1.5.1.4 $    BY: Hareesh V.            DATE: 01/23/03  ECO: *N24Z*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable ext_cost   like pod_pur_cost                no-undo.
define variable descr      as   character    format "X(13)" no-undo.
define variable reqnbr     like req_nbr                     no-undo.
define variable ponbr      like po_nbr                      no-undo.
define variable po_inquiry like mfc_logical                 no-undo.

/* SELECTION FRAME */

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
space(4)
   ponbr              label "PO Nbr"
   space(4)
   reqnbr             label "Req Nbr"
with frame a attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* PO INQUIRY FRAME */
FORM /*GUI*/ 
   rqpo_po_line        label "Ln"
   rqpo_req_nbr        label "Req"
   rqpo_req_line       label "Ln"
   descr               label "Description"
   pod_acct
   pod_sub             label "Sub-Acct"
   pod_cc              label "CC"
   ext_cost
   pod_qty_ord
/* zyf 11/10
   skip
   pod_qty_ord         at 58
*/   
with STREAM-IO /*GUI*/  frame poframe down width 100.

/* SET EXTERNAL LABELS */
setFrameLabels(frame poframe:handle).

/* REQ INQUIRY FRAME */
FORM /*GUI*/ 
   rqpo_req_line       label "Ln"
   rqpo_po_nbr         label "Order"
   rqpo_po_line        label "Ln"
   descr               label "Description"
   pod_acct
   pod_sub             label "Sub-Acct"
   pod_cc              label "CC"
   ext_cost
   pod_qty_ord
/*   skip
   pod_qty_ord         at 58
*/   
with STREAM-IO /*GUI*/  frame reqframe down width 100.

/* SET EXTERNAL LABELS */
setFrameLabels(frame reqframe:handle).

ststatus = stline[1].
status input ststatus.

{wbrp01.i}

repeat:

   if c-application-mode <> 'WEB'
   then
      update ponbr with frame a
      editing:
         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i rqpo_ref ponbr rqpo_po_nbr
            ponbr rqpo_po_nbr rqpo_po_nbr}

         if recno <> ?
         then
            display
               rqpo_po_nbr @ ponbr
            with frame a.
      end.  /* UPDATE ponbr */

   if c-application-mode <> 'WEB'
   then
      update reqnbr with frame a
      editing:
         /* FIND NEXT/PREVIOUS RECORD  */
         {mfnp.i rqpo_ref reqnbr rqpo_req_nbr
            reqnbr rqpo_req_nbr rqpo_req_nbr}

         if recno <> ?
         then
            display
               rqpo_req_nbr @ reqnbr
            with frame a.
      end. /* UPDATE reqnbr */

   {wbrp06.i &command = update &fields = "ponbr reqnbr"  &frm = "a"}

   hide frame poframe.
   clear frame poframe all.

   hide frame reqframe.
   clear frame reqframe all.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 100
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


   /* IF ONLY PO# HAS BEEN SPECIFIED THEN SORT BY PO# AND         */
   /* DISPLAY ALL CROSSREF RECORDS FROM THAT PO ONWARDS           */
   /* IF ONLY REQ# HAS BEEN SPECIFIED THEN SORT BY REQ# AND       */
   /* DISPLAY ALL CROSSREF RECORDS FROM THAT REQ# ONWARDS         */
   /* IF BOTH HAVE BEEN SPECIFIED THEN SORT BY PO# AND            */
   /* DISPLAY ALL CROSSREF RECORDS FROM THAT PO# AND REQ# ONWARDS */

   if ponbr <> ""
   then do:
      po_inquiry = yes.
      for each rqpo_ref
         fields(rqpo_po_line rqpo_po_nbr rqpo_req_line rqpo_req_nbr)
         where rqpo_po_nbr = ponbr
         no-lock,
         each rqd_det
            fields(rqd_line rqd_nbr)
            where rqd_nbr  = rqpo_req_nbr
            and   rqd_line = rqpo_req_line
            no-lock,
            each pod_det
               fields(pod_acct pod_cc pod_desc pod_disc_pct pod_line
                      pod_nbr pod_part pod_pur_cost pod_qty_ord pod_sub)
               where pod_nbr  = rqpo_po_nbr
               and   pod_line = rqpo_po_line
               no-lock
               by rqpo_po_nbr by rqpo_po_line:

         /* IF BOTH PO # AND REQUISTION# HAVE BEEN SPECIFIED, */
         /* THEN START AT THAT PO# AND REQ#                   */
         if  reqnbr       <> ""
         and rqpo_req_nbr < reqnbr
         then
            next.

         if  pod_desc <> ""
         and pod_desc <> getTermLabel("ITEM_NOT_IN_INVENTORY",24)
         then
            descr = pod_desc.
         else
            descr = pod_part.

         display
            rqpo_po_line
            rqpo_req_nbr
            rqpo_req_line
            descr
            pod_acct
            pod_sub
            pod_cc
            (pod_pur_cost * pod_qty_ord * (1 - pod_disc_pct / 100)) @ ext_cost
            pod_qty_ord
         with frame poframe STREAM-IO /*GUI*/ .
         down 1
         with frame poframe.

      end. /* FOR EACH rqpo_ref */
   end.  /* IF ponbr <> "" */
   else do:
      po_inquiry = no.
      for each rqpo_ref
         fields(rqpo_po_line rqpo_po_nbr rqpo_req_line rqpo_req_nbr)
         where rqpo_req_nbr = reqnbr
         no-lock,
         each rqd_det
            fields(rqd_line rqd_nbr)
            where rqd_nbr  = rqpo_req_nbr
            and   rqd_line = rqpo_req_line
            no-lock,
            each pod_det
               fields(pod_acct pod_cc pod_desc pod_disc_pct pod_line
                      pod_nbr pod_part pod_pur_cost pod_qty_ord pod_sub)
               where pod_nbr  = rqpo_po_nbr
               and   pod_line = rqpo_po_line
               no-lock
               by rqpo_po_nbr by rqpo_po_line:

         if  pod_desc <> ""
         and pod_desc <> getTermLabel("ITEM_NOT_IN_INVENTORY",24)
         then
            descr = pod_desc.
         else
            descr = pod_part.

         display
            rqpo_req_line
            rqpo_po_nbr
            rqpo_po_line
            descr
            pod_acct
            pod_sub
            pod_cc
            (pod_pur_cost * pod_qty_ord * (1 - pod_disc_pct / 100)) @ ext_cost
            pod_qty_ord
         with frame reqframe STREAM-IO /*GUI*/ .
         down 1
         with frame reqframe.

      end. /* FOR EACH rqpo_ref */
   end.  /* ELSE DO FOR rqnbr  */
   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.   /* REPEAT  */

status input.

{wbrp04.i &frame-spec = a}
